package MysqlDataSource.SpringDataSource;


import com.mchange.v2.c3p0.ComboPooledDataSource;
import org.junit.jupiter.api.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.sql.Connection;


public class MySpringTest {

    @Test
    //测试Spring容器创建c3p0数据源对象（加载properties配置文件）
    public void test01() throws Exception {
        ApplicationContext context = new ClassPathXmlApplicationContext("SpringDataSource.xml");
        ComboPooledDataSource dataSource = (ComboPooledDataSource) context.getBean("dataSource");
        Connection conn= dataSource.getConnection();
        System.out.println(conn);
        conn.close();
    }
}
